package com.hxj.docking.web.controller;

import com.hxj.docking.pojo.dto.ReceiveDataDTO;
import com.hxj.docking.pojo.dto.ReceiveResultDTO;
import com.hxj.docking.service.ReceiveService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author hxj
 * @Date 2024/12/5 15:32
 * @Description
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/receive")
public class ReceiveController {

    private final ReceiveService receiveService;

    @PostMapping("/data")
    public ReceiveResultDTO receiveData(ReceiveDataDTO receiveDataDTO) {
        // 接口鉴权
        ReceiveResultDTO receiveResultDTO = receiveService.checkSafety(receiveDataDTO);
        if (!ReceiveResultDTO.isSuccess(receiveResultDTO)) {
            return receiveResultDTO;
        }


        return receiveService.receiveData(receiveDataDTO);
    }

}
